package com.bindapp.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;

import com.bindapp.R;
import com.bindapp.databinding.ItemTab2DeviceBinding;
import com.bindapp.databinding.ItemTab2HeadBinding;
import com.bindapp.listener.RecyclerItemClick;
import com.youth.banner.listener.OnBannerListener;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by apple on 2018/6/26.
 */

public class MainTab2Adapter extends BaseRcAdapter {
    private Context context;
    private OnBannerListener click;
    private String txtImgStr = "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3266514659,532374305&fm=27&gp=0.jpg";
    private List<String> pathlist;

    private String[] textlist=new String[]{"公共区海豚池","公共区贝壳池","VIP区海螺池"};

    public MainTab2Adapter(Context context,List<Object> datas, int layoutId, int mVariableId, RecyclerItemClick listener,OnBannerListener click) {
        super(datas, layoutId, mVariableId, listener);
        this.context=context;
        pathlist=new ArrayList<String>();
        this.context=context;
        this.click=click;
        for(int i=0;i<10;i++){
            pathlist.add(txtImgStr);
        }
    }

    @Override
    public void BinderHolder(final BaseHolder holder, final int position) {
        if(holder instanceof HeadHolder){
            Log.e("Mytext","HeadHolder-->"+position);
            ((ItemTab2HeadBinding)holder.getBinding()).cjview.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    listener.onMoreClick(view,position);
                }
            });
            /*Banner banner = ((ItemTab2HeadBinding)holder.getBinding()).banner;
            banner.setIndicatorGravity(BannerConfig.CENTER);
            banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
            banner.setBannerAnimation(Transformer.Default);
            banner.setImages(pathlist);
            banner.setImageLoader(new GlideRoundImageLoader());
            banner.setDelayTime(2000);
            banner.setOnBannerListener(click);

            banner.isAutoPlay(true);
            banner.start();*/

        }else if(holder instanceof ContentHolder){

            ((ItemTab2DeviceBinding)holder.getBinding()).devicename.setText(textlist[(position-1)]);

            ((ItemTab2DeviceBinding)holder.getBinding()).jkview.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    listener.onMoreClick(view,position);
                }
            });

            ((ItemTab2DeviceBinding)holder.getBinding()).carmeraBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    listener.onMoreClick(view,position);
                }
            });

            ((ItemTab2DeviceBinding)holder.getBinding()).togglebtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    //listener.onMoreClick(view,position);
                    if(((ItemTab2DeviceBinding)holder.getBinding()).conlayout2.getVisibility()==View.GONE){
                        ((ItemTab2DeviceBinding)holder.getBinding()).conlayout2.setVisibility(View.VISIBLE);
                        ((ItemTab2DeviceBinding)holder.getBinding()).togglebtn.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.deviceimg_up));
                    }else{
                        ((ItemTab2DeviceBinding)holder.getBinding()).conlayout2.setVisibility(View.GONE);
                        ((ItemTab2DeviceBinding)holder.getBinding()).togglebtn.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.deviceimg_down));
                    }

                }
            });

            /*((ItemTab2DeviceBinding)holder.getBinding()).devicelabel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    listener.onMoreClick(view,position);
                }
            });*/



        }

    }


}
